package cz.cuni.mff.ufal.volk.langr;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

import cz.cuni.mff.ufal.volk.langr.NgramLanguageRecognizer.Mode;

public class Train {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		if (args.length != 2) {
			System.err.println("Train input_directory output_file");
			System.exit(1);
		}

		File inputDirectory = new File(args[0]);
		File outputFile = new File(args[1]);

		NgramLanguageRecognizer rec = new NgramLanguageRecognizer(Mode.Normal);
		rec.train(inputDirectory, 5);
		FileOutputStream fileOut = new FileOutputStream(outputFile);
		try {
			ObjectOutputStream out = new ObjectOutputStream(fileOut);
			try {
				out.writeObject(rec);
			} finally {
				out.close();
			}
		} finally {
			fileOut.close();
		}
	}

}
